home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dirut / dirm13.zip / DIRM13.ASM < prev    next >
Assembly Source File  |  1990-11-02  |  48KB  |  1,272 lines

  1. ;-----------------------------------------------------------------------;
  2. ; This is the main source code for DIRM v1.3, a FAST! directory lister. ;
  3. ; It is the copyrighted property of Michael P. Rice. (c) 1990.          ;
  4. ; This source code is NOT in the public domain and cannot be used       ;
  5. ; commercially without permission.  Completed 2-November-1990.          ;                                               ;
  6. ;-----------------------------------------------------------------------;
  7. .model small
  8.  
  9. .data
  10. ;-----------------------------------------------------------------------;
  11. ; The following table is used in the write_time procedure.  The bits    ;
  12. ; are used as follows:  Bits     6,7   Unused                           ;
  13. ;                                  5   Space flag 0=off 1=on            ;
  14. ;                                  4   Am\Pm flag 0=am 1=pm             ;
  15. ;                            3,2,1,0   Hour to print                    ;
  16. ;-----------------------------------------------------------------------;
  17. time_table      db      0ch,21h,22h,23h,24h,25h,26h,27h,28h,29h,0ah,0bh
  18.                 db      1ch,31h,32h,33h,34h,35h,36h,37h,38h,39h,1ah,1bh
  19.  
  20. ;-----------------------------------------------------------------------;
  21. ; This is a simple table to determine AM/PM for write_time.             ;
  22. ;-----------------------------------------------------------------------;
  23. am_pm_table     db      'a','p'
  24.  
  25. def_filespec    db      '*.*',0
  26. volumespec      db      '*.*',0
  27. filespec        db      13 dup (0)
  28. filespec2       db      13 dup (0)      ; SS
  29.  
  30. ;-----------------------------------------------------------------------;
  31. ; These are used for attribute processing.  Default is attributes will  ;
  32. ; not be printed.  File mask 31h means hidden and system files are not  ;
  33. ; show in the directory.  When attributes are on, system and hidden     ;
  34. ; files are shown with mask=37h                                         ;
  35. ;-----------------------------------------------------------------------;
  36. attrib_on       db      0
  37. attrib_mask     dw      0031h
  38.  
  39. ;-----------------------------------------------------------------------;
  40. ; These are the ASCIIZ string data messages used in the program.        ;
  41. ;-----------------------------------------------------------------------;
  42. volumemess1     db      'Volume in Drive ',0
  43. volumemess2     db      ' is ',0
  44. volumemess3     db      ' has no label.',0
  45. colon           db      ':',0                           ;SS
  46. dirmess1        db      "DIRM v1.3  Directory of ",0
  47. dirmess2        db      '      Filespec: ',0
  48. dir_braces      db      ' <DIR>       ',0
  49. moremessage     db      'Press any key to continue',0
  50. trailermess0    db      ' bytes in ',0
  51. trailermess1    db      ' File(s)',0
  52. trailermess2    db      ' bytes free. ',0
  53. illegalswitch   db      'Usage: dirm [d:][path specification] [/switches]',0
  54. legalswitches   db      ' /w wide mode  /p page at a time  /a show attribs',0
  55. nofoundpath     db      'Unknown Path | ',0
  56. nofoundswitch   db      'Illegal Switch | ',0
  57.  
  58. ;-----------------------------------------------------------------------;
  59. ; Flags used to indicate the use of a switches /p /w /r.                ;
  60. ;-----------------------------------------------------------------------;
  61. page_flag       db      0
  62. recursive_flag  db      0
  63. wide_flag       db      0
  64.  
  65. ;-----------------------------------------------------------------------;
  66. ; Flags used in PSP processing to detect the need for default params.   ;
  67. ;-----------------------------------------------------------------------;
  68. drive_set       db      0
  69. directory_set   db      0
  70.  
  71. ;-----------------------------------------------------------------------;
  72. ; This is used to keep a count of the files in the directory, not       ;
  73. ; including directory entries.                                          ;
  74. ;-----------------------------------------------------------------------;
  75. files           dw      0
  76.  
  77. ;-----------------------------------------------------------------------;
  78. ; This keeps track of lines printed for the /p page switch. It is set   ;
  79. ; initially to 3 to keep the header on the screen.                      ;
  80. ;-----------------------------------------------------------------------;
  81. filecount       db      3
  82.  
  83. ;-----------------------------------------------------------------------;
  84. ; These are where the drive numbers are stored when a change is needed. ;
  85. ;-----------------------------------------------------------------------;
  86. startdrive      db      0
  87. tempdrive       db      0
  88.  
  89. ;-----------------------------------------------------------------------;
  90. ; These are directory specifications used with INT 21h BIOS calls.      ;
  91. ;-----------------------------------------------------------------------;
  92. root            db      '\',0
  93. directory       db      '\'
  94.                 db      64 dup (?)
  95. tempdir         db      '\'
  96.                 db      64 dup (?)
  97.  
  98. ;-----------------------------------------------------------------------;
  99. ; This is where the filesizes of matching files are accumulated.        ;
  100. ;-----------------------------------------------------------------------;
  101. accum_filesize  dd      00000000h
  102.  
  103. ;-----------------------------------------------------------------------;
  104. ; This is the field to add commas to the filesize, bytes free numbers   ;
  105. ;-----------------------------------------------------------------------;
  106. p_field         db      '   ,   ,   ,   ',0
  107.  
  108.  
  109. .data?
  110.  
  111. ;-----------------------------------------------------------------------;
  112. ; This is the data area used for the disk DTA - Disk Transfer Area.     ;
  113. ;-----------------------------------------------------------------------;
  114. Reserved        db      21 dup (?)      ;Reserved
  115. FAttrib         db       1 dup (?)      ;file's Attribute
  116. FTime           db       2 dup (?)      ;file's time stamp
  117. FDate           db       2 dup (?)      ;file's date stamp
  118. FSize           db       4 dup (?)      ;file's size
  119. FName        db    13 dup (?)    ;ASCIIZ file name
  120.  
  121. ;-----------------------------------------------------------------------;
  122. ; Area to move the command line PSP area switches, directory specs, etc ;
  123. ;-----------------------------------------------------------------------;
  124. PSPBytes        db        1 dup (?)
  125. PSPSpace        db        1 dup (?)
  126. PSPArea         db      7Eh dup (?)
  127.  
  128. ;-----------------------------------------------------------------------;
  129. ; Just what it says: holds the current filesize that will be added to   ;
  130. ; the accumulated file size.                                            ;
  131. ;-----------------------------------------------------------------------;
  132. current_filesize  db    4 dup (?)
  133.  
  134. .stack
  135.  
  136. .code
  137.  
  138.     EXTRN    send_crlf:proc, write_string:proc, write_char:proc
  139.     EXTRN    goto_xy:proc, init_write_char:proc
  140.     EXTRN    SCREEN_X:byte, goto_col:proc
  141.     PUBLIC disk_dir
  142. ;-----------------------------------------------------------------------;
  143. ; This is a C callable function to display a disk directory.            ;
  144. ;-----------------------------------------------------------------------;
  145. disk_dir        PROC
  146.         mov dx,ds
  147.         mov ax,@data
  148.         mov ds,dx                       ;Both DS and ES point to the data
  149.     mov es,ax
  150.         
  151.         mov si,80h                      ;Move the PSP into Memory
  152.         mov di,OFFSET PSPBytes
  153.         mov cx,80h
  154.         rep movsb
  155.         mov ds,ax
  156.  
  157.     call init_write_char        ;Determine screen memory    
  158.  
  159.         mov ah,19h
  160.         int 21h                         ;Get current drive
  161.         mov startdrive,al               ;Save current drive
  162.         mov tempdrive,al
  163.  
  164.         call process_psp                ;Process command switches
  165.         call adjust_filespec            ;Make filespec = filespec.*
  166.  
  167.         mov ah,47h                      ;Save the new temporary directory
  168.         mov si,OFFSET tempdir+1
  169.         mov dl,0
  170.         int 21h
  171.  
  172.         call send_crlf
  173.  
  174.         mov dx,OFFSET Reserved          ;Set up a DTA
  175.     mov ah,1ah
  176.     int 21h
  177.  
  178.     call write_volume        ;Write Volume Message/Volume
  179.     call send_crlf
  180.         
  181.